(*
#directory "_build";;
#load "mlfsqp.cma";;
 *)
module C = Mlfsqp;;
module A = Array;;

(* ---------------------------------------------------------------------- *)
(*  Test0                                                                 *)
(* ---------------------------------------------------------------------- *)

(* x^2 + y^2 + z^2 st 2*x < y /\ 2*y < z /\ 1 < x,y,z < 8*)

let rec pow x n = 
  match n with
      0 -> 1.
    | _ -> x *. pow x (n-1);;

let f0 xs = 
  let x0 = Array.get xs 0 in 
  let x1 = Array.get xs 1 in 
  let x2 = Array.get xs 2 in 
    pow x0 2 +. pow x1 2 +. pow x2 2;;

let c0 which xs = 
  let x0 = Array.get xs 0 in 
  let x1 = Array.get xs 1 in 
  let x2 = Array.get xs 2 in 
    match which with 
        1 -> 
          2. *. x0 -. x1
      | 2 -> 
          2. *. x1 -. x2
      | _ -> failwith "c0";;


print_float (fst (C.maximize f0 c0 2 [| 1.;1.;1.|] [| 8.;8.;8.|]));;
print_float (fst (C.minimize f0 c0 2 [| 1.;1.;1.|] [| 8.;8.;8.|]));;


